/**
 * this show get the time from atomic clock in boulder colorado usa.
 */
package v2c03;

import java.io.IOException;
import java.io.InputStream;
import java.net.InetAddress;
import java.net.Socket;
import java.net.UnknownHostException;
import java.util.Scanner;

/**
 * @author gjunming@gmail.com
 * @version Aug 11, 2009 5:34:47 PM
 */
public class SocketTest {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		try {
			Socket timeServer = new Socket("time-a.timefreq.bldrdoc.gov", 13);
			InetAddress timeAdd = InetAddress.getByName("www.google.com");

			try {
				InputStream inStream = timeServer.getInputStream();
				Scanner in = new Scanner(inStream);

				while (in.hasNextLine()) {
					String line = in.nextLine();
					System.out.println(line);
					for (byte add : timeAdd.getAddress()) {
						// System.out.print(add);
					}
				}
			} finally {
				timeServer.close();
			}
		} catch (UnknownHostException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

	}
}
